#!/bin/bash
#
#******************************************************************************
# xpccut-install (xpccut++ subproject)
#------------------------------------------------------------------------------
##
# \file       	xpccut-install
# \library    	libxpccut++ (for installing libxpccut)
# \author     	Chris Ahlstrom
# \date       	2009-07-31
# \update      2012-06-17
# \version    	$Revision$
# \license    	$XPC_SUITE_GPL_LICENSE$
#
#     The above is modified by the following to remove even the mild GPL
#     restrictions:
#
#     Use this script in any manner whatsoever.  You don't even need to give
#     me any credit.
#
#     However, keep in mind the value of the GPL in keeping software and its
#     descendant modifications available to the community for all time.
#
# Installing header files:
#
#     This script installs only the header files from the XPC CUT library on
#     which the XPC CUT++ library depends.
#
# OBSOLETE:
#
#     Since we now build all the libraries as a unit, there is no longer a
#     need to install the C versions of the libraries that the C++ versions
#     depend on.
#
#     We're keeping this script around in case we need parts of it later.
#
# Setting up ldconfig:
#
#     It also checks out the ldconfig setup for libxpccut++ and provides
#     advice if it doesn't work.
#
#------------------------------------------------------------------------------

libdir="$1"

if [ -d ../xpccut ] ; then

   SUCCESS="yes"
   CURRDIR=`pwd`
   pushd ../xpccut
   if [ $UID == 0 ] ; then

      make install
      if [ $? != 0 ] ; then
         echo "? 'make install' for the XPC CUT library FAILED"
         SUCCESS="no"
      fi
   else
      sudo make install
      if [ $? != 0 ] ; then
         echo "? 'sudo make install' for the XPC CUT library FAILED"
         SUCCESS="no"
      fi
   fi
   popd

   if [ $SUCCESS == "yes" ] ; then
      if test -f /etc/ld.so.conf   \
        -a `echo $(libdir) | grep ^/usr`XXX != "XXX" ; then
         if ! grep -q "$(libdir)" /etc/ld.so.conf; then
            echo "--------------------------------------------------"
            echo "You needed to add $(libdir) to /etc/ld.so.conf."
            echo "Automake will try to fix it for you"
            echo "$(libdir)" >> /etc/ld.so.conf
            if [ $? == 0 ] ; then
               echo "Ok, all fixed."
               ldconfig
            else
               echo ""
               echo "That didn't work.  Please add $(libdir) to"
               echo "/etc/ld.so.conf and run ldconfig as root."
            fi
            echo "--------------------------------------------------"
         fi
      fi
   fi

else

   cat << E_O_F

The XPC CUT++ project requires the XPC CUT (C) source code package to be
installed in the XPC suite's source tree.  Go to
http://xpc-suite.sourceforge.net/ and get the latest
'xpccut-1.x.y-bootstrap.tar.bz2 file, copy it to the directory above the
current directory, and un-tar it.  Then clean the XPC CUT++ project:

   $ ./bootstrap --clean

And then run your XPC CUT++ bootstrap command again.  Then repeat the
"make" and "make install" commands.

E_O_F

   exit 1

fi

#******************************************************************************
# xpccut-install (xpccut++)
#------------------------------------------------------------------------------
# Local Variables:
# End:
#------------------------------------------------------------------------------
# vim: ts=3 sw=3 et ft=sh
#------------------------------------------------------------------------------
